$(function(){
		/*初始化表格*/
		$('#visaBase').datagrid({
    		url:'backvisabasejson',
    		collapsible:true,
    		fit:true,
			fitColumns:true,
			toolbar:'#footer',
			pagination:true,
			pageSize:20,
			pageList:[20,50,100,200],
			remoteSort:false,
   			columns:[[
   			 	{field:'ck',checkbox:true},
   			 	{field:'visaID',hidden:'true'},
				{field:'visaName',title:'签证名称',align:'center',width:'20%'},
				{field:'zoneName',title:'签证区域',align:'center',width:'10%'},
				{field:'type',title:'签证类型',align:'center',width:'8%',formatter: function(value,row,index){
	        	if(value == 0)
	        		return '团签';
				else
				return '个签';
	        }},
				{field:'day',title:'办理周期',align:'center',width:'8%'},
				{field:'floor',title:'租赁底价',align:'center',width:'10%'},
				{field:'peer',title:'租赁同业价',align:'center',width:'10%'},
				{field:'price',title:'对外报价',align:'center',width:'10%'},
	            {field:'memo',title:'备注',align:'center',width:'22%'}
    		]]
		});
			
});

/*搜索*/
function searchVisaBase(){
	
		var visaName = $("#visaBaseName").val();
		var zoneID = $("#visaBaseCountryID").val();
		var type = $("#visaType").val();
		
		$("#visaBase").datagrid("load",{
			visaName:visaName,
			zoneID:zoneID,
			type:type
		})
	}
	
/*清空*/
function clearVisaBase(){
        $("#visaBaseName").val('');
 $("#visaZoneID").val('');

		$('#visaBaseCountryID').val('');
		$("#visaType").val('');
	
     }
function checkZoneIDandType(ckType){
	var iZoneID= $("#visaBaseZoneID").val();
 //判断是否重复 判断签证区域是否已存在  
$.ajax({
        url:"/mmy/isexistvisabase?iZoneID="+iZoneID+"&bType="+ckType,
        type:"post",
        dataType:"text",
        success:function (data) {
   if(data=="1"){
     $.messager.alert('错误','该类型签证已存在，请重新创建！','error');
  	$("#visaBaseType").val('');
   return false;
   }
 if(data=="2"){
     $.messager.alert('错误','该区域所有类型签证已存在，请重新创建！','error');
  $("#visaBaseZoneID").val('');
   return false;
   }
        }
    });

}
//后台	招标新建与修改时正则验证 2020.11.19
function visaBaseSubmit(visaBaseForm){
	var floor=visaBaseForm.Floor.value;
	var peer=visaBaseForm.Peer.value;
	var price=visaBaseForm.Price.value;
	var number=planPlaneForm.Number.value;
if(floor<=0){ 
  $.messager.alert('错误','底价必须大于零','error');
	visaBaseForm.Floor.focus();
	return false;	
    } 
if(peer<=0){ 
  $.messager.alert('错误','同业价必须大于零','error');
	visaBaseForm.Peer.focus();
	return false;	
    } 
if(price<=0){ 
  $.messager.alert('错误','对外报价必须大于零','error');
	visaBaseForm.Price.focus();
	return false;	
    }
if(number<=0){ 
  $.messager.alert('错误','数量必须大于零','error');
	planPlaneForm.Number.focus();
	return false;	
    }
if(parseInt(floor)>=parseInt(peer)) {
	 $.messager.alert('错误','同业价必须大于底价','error');
	visaBaseForm.Peer.focus();
	return false;	
    
}
if(parseInt(peer)>=parseInt(price)) {
	 $.messager.alert('错误','对外报价必须大于同业价','error');
	visaBaseForm.Price.focus();
	return false;	
    }
}
/* 修改签证基本信息 */
	function updateVisaBase(){
		
			var rows = $('#visaBase').datagrid('getSelections');
		var checkNum = rows.length;
		if(checkNum==0){
			$.messager.alert('错误','至少选择一项','error');
		 } else if(checkNum>1){
			$.messager.alert('错误','最多选择一项','error');
		 }else{
		$.messager.confirm('Confirm', '确定要修改吗?', function(r){
	if (r){
		var iVisaID = rows[0].visaID; 
		 	location.href="/mmy/backtoupdatevisabase?iVisaID="+iVisaID;
	}
});	
		 }

				}


